﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SVN.Net.Models
{
    public partial class SVN
    {
        public class SvnException : Exception
        {
            public SvnException(string error)
                : base(error)
            {
            }
        }

        public class ProcessResult
        {
            public bool Success
            {
                get;
                private set;
            }

            public string Result
            {
                get;
                private set;
            }

            public SvnException Error
            {
                get;
                private set;
            }

            public ProcessResult(bool success, string result, string error)
            {
                Success = success;
                Result = result;
                Error = new SvnException(error);
            }
        }

        public class ProcessXmlResult : ProcessResult
        {
            public System.Xml.XmlDocument XmlResult
            {
                get;
                private set;
            }

            public ProcessXmlResult(bool success, string result, string error)
                : base(success, result, error)
            {
                if (Success)
                {
                    XmlResult = new System.Xml.XmlDocument();
                    XmlResult.LoadXml(Result);
                }
                else
                    XmlResult = null;
            }

            public ProcessXmlResult(ProcessResult result)
                : this(result.Success, result.Result, result.Error.Message)
            {
            }
        }
    }
}
